﻿using System;




#if NETSTANDARD2_0
using System.Threading;
using System.Threading.Tasks;
#endif

namespace Kernelx.Contexts.Repositories
{
    using Core;

    /// <summary>
    /// 定义模型库操作接口,提供针对实体模型的必要方法
    /// </summary>
    public interface IModelibOfWork : IDisposable
    {

        /// <summary>
        /// 
        /// </summary> 
        /// <returns></returns>
        ITransaction BeginTransaction();

        /// <summary>
        /// 获取当前是否处于事务执行中
        /// </summary>
        bool IsTransactioning { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetName"></param>
        /// <returns></returns>
        IModelStore<T> Store<T>(string targetName = null) where T : class, new();



        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int SaveChanges();


#if NETSTANDARD2_0

        /// <summary>
        /// 
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task<int> SaveChangesAsync(CancellationToken token = default);

#endif


    }
}
